<template>
<h1>循环指令</h1>
  <ul>
    <li v-for="item in 10">{{item}}</li>
  </ul>
  <ul v-for="item in 10">
    <li>大家好</li>
    <li >我是威神</li>
    <li >大家都叫我威哥哥</li>
    <li >你们也可以叫我威哥哥</li>
    <li >或者威哥</li>
  </ul>
  <ul>
    <li v-for="n in arr">{{n}}</li>
  </ul>
  <hr>
  <table border="1">
  <tr>
    <th>商品序号</th>
    <th>商品名称</th>
    <th>商品价格</th>
    <th>商品库存</th>
  </tr>
  <tr v-for="(item,index) in x">
    <td>{{index+1}}</td>
    <td>{{item.title}}</td>
    <td>{{item.price}}</td>
    <td>{{item.num}}</td>
    <td><button @click="del(index)">删除</button></td>
  </tr>
  </table>

</template>

<script setup>
  import {ref} from "vue";
  import index from "vuex";


  const arr = ref(['大家好', '我是威神', '大家都叫我威哥哥', '你们也可以叫我威哥哥', '或者威哥'])

  const x = ref([
    {title:"苹果17",price:6999,num:100},
    {title:"苹果16",price:4999,num:200},
    {title:"苹果15",price:3999,num:300},
    {title:"威图手机",price:2476999,num:400},
    {title:"苹果17proMAX",price:16999,num:500}
  ])

  //定义删除的方法
  const del = (index)=>{
    if (confirm('您确定删除吗？')){
    x.value.splice(index,1);
   }
  }


</script>



<style scoped>

</style>